package rbm.modelado.soluciones;
import java.util.Vector;

import rbm.modelado.datos.elementos.BlockPosNode;
import rbm.modelado.datos.elementos.PathImpl;
import rbm.modelado.datos.elementos.interfaces.Path;
import rbm.modelado.global.interfaces.PuzzleConstants;

public class Solution implements PuzzleConstants
{

   private Boolean isSolvable;
   private Path path;
   private Integer pathLength;
   private Integer numBranches;
   private Integer numNodes;
   private Integer numDirectionChanges;	// Direction changes along longest path

   private Integer totalLoopLength;
   private Integer numLoops;

   private BlockPosNode bestFinishNode;
   private BlockPosNode longestPathNode;
   private BlockPosNode mostBranchesNode;
   private Vector edgeList;	// Sufficient to built whole graph


   public Solution( BlockPosNode longestPath, BlockPosNode mostBranches, Integer nodes,
		   Integer numDirCh, Integer loopLength, Integer loopNum, Vector eList )
   {
      isSolvable = false;
      path = new PathImpl(0);
      pathLength = 0;
      numBranches = 0;
      bestFinishNode = null;
      longestPathNode = longestPath;
      mostBranchesNode = mostBranches;
      edgeList = null;
      numNodes = nodes;
      numDirectionChanges = numDirCh;
      totalLoopLength = loopLength;
      numLoops = loopNum;
      edgeList = eList;
   }


   public Solution( Path p, BlockPosNode bestFin, BlockPosNode longestPath,
      BlockPosNode mostBranches, Integer nodes, Integer numDirCh, Integer loopLength, Integer loopNum, Vector eList )
   {
      isSolvable = true;
      path = p;
      pathLength =  p.length();
      numBranches = bestFin.getNumBranches();
      bestFinishNode = bestFin;
      longestPathNode = longestPath;
      mostBranchesNode = mostBranches;
      numNodes = nodes;
      numDirectionChanges = numDirCh;
      totalLoopLength = loopLength;
      numLoops = loopNum;
      edgeList = eList;
   }


   public boolean isSolvable()
   {
      return isSolvable;
   }

   public Path getPath()
   {
      return path;
   }

   public Integer getSolutionLength()
   {
      return pathLength;
   }

   public Integer getNumBranches()
   {
      return numBranches;
   }

   public BlockPosNode getBestFinishNode()
   {
      return bestFinishNode;
   }

   public BlockPosNode getLongestPathNode()
   {
      return longestPathNode;
   }

   public BlockPosNode getMostBranchesNode()
   {
      return mostBranchesNode;
   }

   public Vector getEdgeList()
   {
      return edgeList;
   }

   public int getNumNodes()
   {
      return numNodes;
   }

   public int getNumDirectionChanges()
   {
      return numDirectionChanges;
   }

   public int getTotalLoopLength()
   {
      return totalLoopLength;
   }

   public int getNumLoops()
   {
      return numLoops;
   }


	// Returns x-coordinate of the node at the end of the
	// longest path in the puzzle

   public int getLongX()
   {
      return longestPathNode.getXPos();
   }

	// Returns y-coordinate

   public int getLongY()
   {
      return longestPathNode.getYPos();
   }

}